﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Controls;
using System.Windows.Media.Media3D;
using System.Windows.Threading;

namespace FlyingCell
{
    class Cell : UserControl3D
    {
        public Cell(string Name)
        {
            CellUC TmpUC = new CellUC();
            TmpUC.Cell_Title.Text = Name;

            base.Initialize(Name, (MeshGeometry3D)TmpUC.Resources["Cell_Geometry"], TmpUC);
        }

        public override void StartUpdateContent(DispatcherObject Disp)
        {
            new Thread((ThreadStart)delegate()
            {
                // TODO: very simplistic update here!
                Random Rnd = new Random();
                Thread.Sleep(Rnd.Next(1, 5000));

                CallBaseUpdate(Disp);
            }).Start();
        }

        /// <summary>
        /// Helper method
        /// </summary>
        /// <param name="Disp">DispatcherObject</param>
        private void CallBaseUpdate(DispatcherObject Disp)
        {
            base.StartUpdateContent(Disp);
        }
    }
}
